//
//  ViewController.m
//  12.Image Collision
//
//  Created by iD Student on 7/8/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    originalFrameA = imageViewA.frame;
    originalFrameB = imageViewB.frame;
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchpoint = [touch locationInView:[self view]];
    if(CGRectContainsPoint(imageViewA.frame, touchpoint))
    {
        [UIView animateWithDuration:5 animations:^{
            imageViewA.frame = CGRectMake(imageViewA.frame.origin.x - 150, imageViewA.frame.origin.y - 150, imageViewA.frame.size.width + 300, imageViewA.frame.size.height + 300);
        }];
    }
    else if (CGRectContainsPoint(imageViewB.frame, touchpoint))
    {
        [UIView animateWithDuration:5 animations:^{
            imageViewB.frame = CGRectMake(imageViewB.frame.origin.x - 150, imageViewB.frame.origin.y - 150, imageViewB.frame.size.width + 300, imageViewB.frame.size.height + 300);
        }];
    }
}

- (IBAction)reset:(id)sender
{
    [imageViewA stopAnimating];
    [imageViewB stopAnimating];
    imageViewA.frame = originalFrameA;
    imageViewB.frame = originalFrameB;
}

@end
